/** @file  read.c
 *  @brief  read the data from file
 * 
 *   display the records in the database 
 *   
 *  @author Karthik M 
 *  @bug No  bugs.
 */



//! to check


#include "header.h"



void read ( char *database, char  * line )
{
   FILE *fp ;
   DATA record;

   int i = 65;
   int j = 97;
   int k;
  
#if 0 
   printf (" the file name is %s \n", database );
#endif

   if (! (fp = fopen (database,"r")) )
      errno_abort(" READ OPEN FAILED ");


   fread ( &record,sizeof(record),1,fp);
   if (record.name == NULL) {
      fprintf (stderr," EMPTY DATABASE \n");
      return;
   }
   for ( ; i<= 90 && j <= 122; ) {
      rewind(fp);
      while (fread ( &record,sizeof(record),1,fp)){
         k = *(record.name);
#if DEBUG
          printf (" num = %d i %d j %d\n",k,i,j);
#endif
         if  (( k == i) || (k == j)) 
            print (record );

         //    if (feof(fp))
         //       break;

      }
      i++;
      j++;
   }


}

